package com.qzsoft.zhjd.machine.modules.machinereport.dto;

import java.math.BigDecimal;
import java.math.RoundingMode;

import com.qzsoft.jeemis.common.annotation.Dict;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;

/**
 * @ClassName MachineReportUseRateDto
 * @Description 机械设备使用率
 * @author linhuawei
 * @since 2021-11-09
 */
@Data
@EqualsAndHashCode(callSuper = false)
@NoArgsConstructor
@AllArgsConstructor
@Builder
@ToString
public class MachineReportUseRateDto {

    /**
     * 设备主键
     */
    private String machineId;

    /**
     * 机械名称
     */
    private String machineName;

    /**
     * 机械类型
     */
    @Dict(dicCodeField = "machineType", dictCodeId = "MACHINE_TYPE")
    private String machineType;

    /**
     * 机械一级分类
     */
    @Dict(dicCodeField = "machineCategory1", dictCodeId = "MACHINE_CATEGORY")
    private String machineCategory1;

    /**
     * 机械二级分类
     */
    @Dict(dicCodeField = "machineCategory2", dictCodeId = "MACHINE_CATEGORY")
    private String machineCategory2;

    /**
     * 机械品牌
     */
    @Dict(dicCodeField = "machineBrand", dictCodeId = "MACHINE_BRAND_MODEL")
    private String machineBrand;

    /**
     * 机械型号
     */
    @Dict(dicCodeField = "machineModel", dictCodeId = "MACHINE_BRAND_MODEL")
    private String machineModel;

    /**
     * 工作时长
     */
    private Long workTime;

    /**
     * 怠速时长
     */
    private Long idleTime;

    /**
     * 静止时长
     */
    private Long offTime;

    /**
     * 有效工作时长
     */
    private Long effectiveTime;

    /**
     * 台班数
     */
    private BigDecimal taiban;

    /**
     * 统计天数
     */
    private Integer days;

    /**
     * 使用率
     */
    private BigDecimal rate;

    /**
     * @Title count
     * @Description 计算使用率
     */
    public void count() {
        if (null != taiban && null != days) {
            rate = taiban.multiply(new BigDecimal(100)).divide(new BigDecimal(days), 2, RoundingMode.HALF_UP);
        }
    }

}
